package com.cebbank.yyi.springbootapp.jingtang.controller;

import com.cebbank.yyi.springbootapp.jingtang.entity.RcDoc;
import com.cebbank.yyi.springbootapp.jingtang.service.RcDocService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 文档(RcDoc)表控制层
 *
 * @author makejava
 * @since 2024-08-22 10:52:58
 */
@RestController
@RequestMapping("rcDoc")
public class RcDocController {
    /**
     * 服务对象
     */
    @Resource
    private RcDocService rcDocService;

//    /**
//     * 分页查询
//     *
//     * @param rcDoc       筛选条件
//     * @param pageRequest 分页对象
//     * @return 查询结果
//     */
//    @GetMapping
//    public ResponseEntity<Page<RcDoc>> queryByPage(RcDoc rcDoc, PageRequest pageRequest) {
//        return ResponseEntity.ok(this.rcDocService.queryByPage(rcDoc, pageRequest));
//    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<RcDoc> queryById(@PathVariable("id") String id) {
        return ResponseEntity.ok(this.rcDocService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param rcDoc 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<RcDoc> add(RcDoc rcDoc) {
        return ResponseEntity.ok(this.rcDocService.insert(rcDoc));
    }

    /**
     * 编辑数据
     *
     * @param rcDoc 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<RcDoc> edit(RcDoc rcDoc) {
        return ResponseEntity.ok(this.rcDocService.update(rcDoc));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(String id) {
        return ResponseEntity.ok(this.rcDocService.deleteById(id));
    }

}

